package android;

import java.util.HashMap;
import java.util.Map;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.content.pm.LauncherApps.Callback;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Message;
import android.preference.PreferenceManager;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
import android.view.WindowManager;
import android.widget.Toast;

/**
 * @author diwj
 * 2015/12/22
 *
 */

public class ExtraInfoPlugin extends CordovaPlugin {

    public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
            throws JSONException {
    Log.d("----debug---", args.getJSONObject(0).toString());
        JSONObject param = args.getJSONObject(0); // 获取json参数
        if (action.equals("getExtra")) {

           showToast(param.getString("content"));

           callbackContext.success("1111111");
            return true;
        }
        callbackContext.error("error");
        return false;
    }

    private void showToast(String text){
       android.widget.Toast.makeText(this.cordova.getActivity(), text, 1).show();
     }
}